﻿Public Class xtf_ABMemail 
    Public obj_email As cls_email_ = Nothing
    Private col_ControlesValidar As List(Of Control)

    Public Sub New()
        InitializeComponent()
        CargarTipoEmail_()
        Me.Text = "Email - Nuevo"
        obj_email = New cls_email_
        AgregarValidacionesGlobal(Me, Me.lac_general, col_ControlesValidar)
    End Sub

    Private Sub CargarTipoEmail_()
        Dim tipoemail_ As New cls_tipoemail_
        tipoemail_.CargarTodos()
        cargarCombo(cbo_TipoEmail, tipoemail_.Items)
    End Sub


    Public Sub Modificar(ByRef email As cls_email_)
        If IsNothing(obj_email) Then
            obj_email = New cls_email_
        End If
        obj_email = email

        Me.Text = "Email - " & obj_email.ToString
        'txt_ID.Text = obj_localidad.idlocalidad
        cbo_TipoEmail.EditValue = email.idtipoemail
        txt_EMail.Text = obj_email.email

        obj_email.tipoemail = Nothing
    End Sub


    Public Function ComprobarDatos() As Boolean
        'If cbo_TipoEmail.Enabled = False Then
        '    ErrManagerShow("001019")
        '    Return False
        'End If
        If Not ControlarValidacionesGlobal(col_ControlesValidar) Then
            ErrManagerShow("000004", Me)
            Return False
        End If
        Return True
    End Function

    Private Sub btn_Guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Guardar.Click
        If ComprobarDatos() Then
            obj_email.idtipoemail = cbo_TipoEmail.EditValue

            obj_email.email = txt_EMail.Text
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If

    End Sub

    Private Sub btn_Cerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Cerrar.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
End Class